<%--
  Created by IntelliJ IDEA.
  User: Administrator
  Date: 2021/11/15
  Time: 10:21
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
        <script type="text/javascript" src="/static/js/jquery-3.6.0.js"></script>
</head>
<body>
<div>
    <input type="button" id="btn" value="查询1">

</div>
<div id="info"></div>
<script>
    $(function () {
$("#btn").click(function () {
$.ajax({
    type:"post",
    url:"${pageContext.request.contextPath}/student/redisTest1",
    dataType:"json",
    contentType:"application/json; charset=utf-8",
    success:function (students) {
//         let msg="<ul>";
//         $.each(students,function (i,o) {
// msg+="<li>"+o.sno+"&nbsp;&nbsp;"+o.sname+"</li>";
//         })
//         msg+="</ul>";
//         // alert(students)
//         console.log(students);
// $("#info").html(msg);

        let msg="<ul>";
        $.each(JSON.parse(students.students),function (i,o) {
            msg+="<li>"+o.sno+"&nbsp;&nbsp;"+o.sname+"</li>";
        })
        msg+="</ul>";
        // alert(students)
        console.log(students);
        $("#info").html(msg);

    }
});

});
    });
</script>
</body>
</html>
